package com.zoshine.zzg.controller;

import com.zoshine.zzg.base.BaseResponse;
import com.zoshine.zzg.pojo.Report;
import com.zoshine.zzg.respons.AppResponse;
import com.zoshine.zzg.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 报表控制器
 * @author 贾俊峰
 * @time 2017/7/9 14:26
 */
@RestController
@RequestMapping(value = "report", method = RequestMethod.POST)
public class ReportController {
    private ReportService reportService;
    @Autowired
    public void setReportService(ReportService reportService) {
        this.reportService = reportService;
    }

    @RequestMapping("pageReport")
    public BaseResponse pageReport(Report report) {
        List<Report> reportList = reportService.list(report);
        return new AppResponse(reportList);
    }

    @RequestMapping("getReport")
    public BaseResponse getReport(Long id) {
        return new AppResponse(reportService.get(id));
    }

    @RequestMapping("addReport")
    public BaseResponse addReport(Report report) {
        reportService.add(report);
        return AppResponse.OK;
    }
}
